package com.cjm.mybatis.test3;

import com.cjm.mybatis.bean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by jiaming.chen1 on 2015/7/7.
 */
public interface UserMapper {
    @Insert("INSERT INTO users(NAME,age) VALUES (#{name}, #{age})")
    public int addUser(User user);

    @Delete("DELETE FROM users WHERE id=#{id};")
    public int deleteById(int id);

    @Update("UPDATE users SET NAME=#{name},age=#{age} WHERE  id=#{id}")
    public int updateUser(User user);

    @Select("select * from users where id=#{id}")
    public User getUser(int id);

    @Select("SELECT * FROM users")
    public List<User> getAllUser();
}
